#!/bin/bash

function print_usage()
{
   echo "Usage: $0 <opl file>"
   echo "Generate Skeys file"
}

file=$1

if [ "x$file" == "x" ]; then
   echo "`date +'%Y/%m/%d %H:%M:%S'` [ERROR] All arguments not available."
   print_usage
   exit 1
fi

#cat /data/samba_share/huawei/opl/done/00015963.000 | awk -F ";" '{print $1";"$29";"$30";"$31";;;"$34";" }' | sed s/\ //g > list
# $29 N
# $30 NS
# $31 SP
# $34 RC

cat $1 | awk -F ";" '{print $1";"$29";"$30";"$31";;;"$34";" }' | sed s/\ //g > list

#skeysFile=$1 # list

#for i in `cat $skeysFile`
for i in `cat list`
  do
  fileName=`echo $i | awk -F ";" '{ print $1 }'` 
  echo $i > /data/samba_share/simlocks/keys/$fileName".skeys"
done
